from django.db import models
from django.contrib.auth.models import AbstractUser
# from django_mysql.models import JSONField

# Create your models here.
class User(AbstractUser):
    gender = models.IntegerField(default=0, verbose_name='性别' )  # 0未知 1男 2女
    birthday = models.DateTimeField(null=True,blank=True, verbose_name='生日')
    text = models.CharField(max_length=200, default='这个人很懒， 什么也没留下', verbose_name='个性签名')
    tel = models.CharField(max_length=11, verbose_name='手机号')
    default_image = models.CharField(max_length=150, blank=True, null=True,
                                     default='http://134.175.230.195:5555/s/static/s/image_files/user666.png',
                                     verbose_name='默认头像')

    #  course_id = models.UUIDField(auto_created=True, default=uuid4, editable=False, unique=True, db_index=True)
    # 外键关联     course = models.ForeignKey(CourseInfo, to_field="course_id")
    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

class BaseModel(models.Model):
    """为模型类补充字段"""

    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        abstract = True  # 说明是抽象模型类, 用于继承使用

class Friend(BaseModel):
    user_a = models.ForeignKey(User, related_name='user_a', on_delete=models.CASCADE, verbose_name='用户a')
    user_b = models.ForeignKey(User, related_name='user_b', on_delete=models.CASCADE, verbose_name='用户b')
    mew_data = models.CharField(null=True, blank=True, max_length=500, verbose_name='最新聊天信息')
    status = models.IntegerField(default=0, verbose_name='关系状态')
    class Meta:
        db_table = 'tb_friends'
        verbose_name = '好友表'
        verbose_name_plural = verbose_name




